/**
 * 工作项相关类型定义
 */

export interface WorkItem {
  id: string;
  url: string;
  identifier: string;
  title: string;
  type: string;
  start_at?: number;
  end_at?: number;
  parent_id?: string;
  parent?: {
    id: string;
    url: string;
    identifier: string;
    title: string;
    type: string;
  };
  assignee?: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  state: {
    id: string;
    url: string;
    name: string;
    type: string;
    color: string;
  };
  priority?: {
    id: string;
    url: string;
    name: string;
  };
  project: {
    id: string;
    url: string;
    identifier: string;
    name: string;
    type: 'scrum' | 'kanban' | 'waterfall' | 'hybrid';
    is_archived: number;
    is_deleted: number;
  };
  version?: {
    id: string;
    url: string;
    name: string;
    start_at: number;
    end_at: number;
  };
  sprint?: {
    id: string;
    url: string;
    name: string;
    start_at: number;
    end_at: number;
    status: string;
  };
  board?: {
    id: string;
    url: string;
    name: string;
    work_item_types: string[];
  };
  entry?: {
    id: string;
    url: string;
    name: string;
  };
  swimlane?: {
    id: string;
    url: string;
    name: string;
  };
  description?: string;
  completed_at?: number;
  story_points?: number;
  estimated_workload?: number;
  remaining_workload?: number;
  properties?: Record<string, any>;
  tags?: Array<{
    id: string;
    url: string;
    name: string;
  }>;
  participants?: Array<{
    id: string;
    url: string;
    type: string;
    user?: {
      id: string;
      url: string;
      name: string;
      display_name: string;
      avatar?: string;
    };
  }>;
  created_at: number;
  created_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  updated_at: number;
  updated_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  is_archived: number;
  is_deleted: number;
}

export interface Project {
  id: string;
  url: string;
  identifier: string;
  name: string;
  type: 'scrum' | 'kanban' | 'waterfall' | 'hybrid';
  assignee?: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  scope_type: string;
  visibility: 'private' | 'public';
  state: {
    id: string;
    url: string;
    name: string;
    type: string;
  };
  start_at?: number;
  end_at?: number;
  color: string;
  description?: string;
  properties?: Record<string, any>;
  members?: Array<{
    id: string;
    url: string;
    type: string;
    user?: {
      id: string;
      url: string;
      name: string;
      display_name: string;
      avatar?: string;
    };
  }>;
  created_at: number;
  created_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  updated_at: number;
  updated_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  is_archived: number;
  is_deleted: number;
}

export interface WorkItemType {
  id: string;
  name: string;
  icon?: string;
  color?: string;
}

export interface WorkItemState {
  id: string;
  name: string;
  type: string;
  color: string;
}

export interface WorkItemPriority {
  id: string;
  name: string;
}

export interface User {
  id: string;
  url: string;
  name: string;
  display_name: string;
  avatar?: string;
}

export interface ApiResponse<T> {
  page_size: number;
  page_index: number;
  total: number;
  values: T[];
  message?: string; // 可选的提示信息
}

export interface WorkItemQueryParams {
  project_id?: string;
  type?: string;
  state_id?: string;
  assignee_id?: string;
  priority_id?: string;
  title?: string;
  identifier?: string;
  created_between?: string;
  updated_between?: string;
  start_date?: string;
  end_date?: string;
  tags?: string[];
  sprint_id?: string;
  version_id?: string;
  board_id?: string;
  entry_id?: string;
  swimlane_id?: string;
  parent_id?: string;
  is_archived?: number;
  is_deleted?: number;
  page_index?: number;
  page_size?: number;
  // 表单临时字段
  dateRange?: any;
  createdRange?: any;
  updatedRange?: any;
}